﻿<?php

/*
 *
 *
 * --------------------------------------------------------------------
 * Copyright (c) 2001 - 2011 Openfiler Project.
 * --------------------------------------------------------------------
 *
 * Openfiler is an Open Source SAN/NAS Appliance Software Distribution
 *
 * This file is part of Openfiler.
 *
 * Openfiler is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * Openfiler is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Openfiler.  If not, see <http://www.gnu.org/licenses/>.
 *
 * --------------------------------------------------------------------
 *
 *
 */

	require("pre.inc");
    include("authenticated.inc");

	if ($_POST["current_password"] && $_POST["new_password"] && $_POST["confirm_new_password"])
	{

		if ($GLOBALS["passcookie"] != $_POST["current_password"])
			$message = "<p><span style=\"color: red; background-color: transparent;\">The supplied current-password does not match the user's current password.</span> Did you enter it correctly?</p>";
		else if ($_POST["new_password"] != $_POST["confirm_new_password"])
			$message = "<p><span style=\"color: red; background-color: transparent;\">The supplied new passwords do not match.</span> Please verify that the new-password and confirm-password fields match.</p>";
		else
		{
			$fp = popen("/usr/bin/sudo /usr/bin/passwd --stdin " . escapeshellarg($GLOBALS["usercookie"]), "w");
			fwrite($fp, $_POST["new_password"] . "\n");
			pclose($fp);
			$message = "<p><span style=\"color: green; background-color: transparent;\">Your password was changed successfully!</span></p>";
		}

	}

	generic_header(array("title" => _("OPENFILER : 帐户 : 系统管理员密码")));
	single_begin(array());

?>

<p>&nbsp;</p>

<?php
        nested_tab_begin("C_ACCOUNTS_ADMIN_PASSWORD");
?>
        <h3>更改系统管理员密码</h3>
	<form action="account_adminpassword.html" method="post">
	<table cellpadding="8" cellspacing="2" border="0">
	<tr>
		<td class="color_table_heading">当前密码：</td>
		<td class="color_table_row1"><input name="current_password" type="password" /></td>
	</tr>
	<tr>
		<td class="color_table_heading">新的密码：</td>
		<td class="color_table_row1"><input name="new_password" type="password" /></td>
	</tr>
	<tr>
		<td class="color_table_heading">确认密码：</td>
		<td class="color_table_row1"><input name="confirm_new_password" type="password" /></td>
	</tr>
	<tr>
		<td colspan="2" align="center"><input name="submit" type="submit" value="更新" /> &nbsp; <input name="reset" type="reset" value="Clear" /></td>
	</tr>
	</table>
	</form>
<?php

	nested_tab_end();

	single_end(array());
	generic_footer(array());
?>
